package com.Except;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author: htj
 * @Date: 2021/10/6 0006 上午 0:20
 */
@Slf4j
@ResponseBody
@RestControllerAdvice
public class ExceptionAdvice {

    //对controller进行统一异常处理
    @ExceptionHandler
    public String handleException(Exception e) {
        log.error("本次异常信息为：{}", e.getMessage());
        return "本次异常信息为：" + e.getMessage();
    }

}
